#include <sys/time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static unsigned int
get_seed () {
    unsigned int ret;
    struct timeval tv;
    gettimeofday (&tv, NULL);
    ret = tv.tv_sec;
    ret *= 1000000;
    ret += tv.tv_usec;
    return ret;
}

/* need free */
char *
get_rand_name () {
    int hmap[26];
    int i;
    unsigned int seed;
    // char ch;
    char *ret, *ptr;
    seed = get_seed ();
    //printf ("seed:%u\n",seed);
    ret = (char*)malloc (sizeof(char) * 27);
    memset (ret, 0, sizeof(char) * 27);
    memset (hmap, 0, sizeof (hmap));
    ptr = ret;
    srand (seed);
    while ((ptr - ret) != 26) {
        i = rand () % 26;
        if (hmap[i] == 0) {
            hmap[i] = 1;
            *ptr = i + 'A';
            ptr++;
        }
    }
    *ptr = 0;
    return ret;
}